<script setup lang="ts">
import { useUserStore } from '@/stores/user'
import router from '@/router'

const userStore = useUserStore()
var username = userStore.userInfo.username
var usertype: string = userStore.userInfo.type

if (usertype == '1') {
  usertype = '实验室用户'
} else if (usertype == '2') {
  usertype = '设备管理员'
} else if (usertype == '3') {
  usertype = '质量办公室用户'
} else if (usertype == '0') {
  usertype = '实验室主管'
}

function logout() {
  router.push({
    name: 'login'
  })
  sessionStorage.clear()
}
</script>

<template>
  <el-dropdown>
    <el-card class="index">
      <div class="info">
        <h3>{{ username }}</h3>
      </div>
    </el-card>
    <template #dropdown>
      <el-dropdown-item @click="logout()">登出</el-dropdown-item>
    </template>
  </el-dropdown>
</template>

<style scoped>
.index {
  height: 50px;

  opacity: 0.3;
  transition-duration: 1s;
}

.index:hover {
  opacity: 1;
  transition-duration: 1s;
}
</style>
